
<template>
    <div id="seachDialog">
      <a-modal
      title="快速筛选"
      width="550px"
      :visible="searchData.show"
      @cancel="handleClose">
        <el-row style="padding:30px 70px 50px 20px;overflow-y:auto;overflow-x:hidden;">
            <el-form :model="searchParames" ref="searchParames" label-width="120px">
                <el-form-item label="服务公司:">
                    <el-select style="width:100%" size="small" clearable v-model="searchParames.serviceCompanyId" placeholder="请选择">
                        <el-option v-for="(item,index) in companyData" :key="index" :label="item.providerName" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="发票抬头:">
                    <el-input clearable size="small" v-model="searchParames.invoiceTitle" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="社会信用代码:">
                    <el-input clearable size="small" v-model="searchParames.creditCode" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="审核状态:">
                    <el-select clearable size="small" v-model="searchParames.reviewStatus" placeholder="审核状态">
                        <el-option label="已审核" value="REVIEWED"></el-option>
                        <el-option label="未审核" value="UNREVIEWED"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="申请人:">
                    <el-input clearable size="small" v-model="searchParames.createBy" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="申请时间:">
                    <el-date-picker
                    style="width:100%"
                    size="small"
                    clearable
                    v-model="searchParames.createDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-form>
        </el-row>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="handleReset">重置</el-button>
            <el-button size="small" type="primary" @click="handleSend">查询</el-button>
        </span>
      </a-modal>
    </div>
</template>

<script>
export default {
    props: ['searchData'],
    data() {
        return {
          searchParames: {
            serviceCompanyId: '',//服务公司
            invoiceTitle:'',//发票抬头
            creditCode:'',//社会信用代码
            createBy:'',//申请人
            createDate:'',//申请时间
            reviewStatus: ''
          },
          companyData: [], //公司信息

        };
    },
    methods: {
        handleSend () {
            let searchDate = []
            for(var key in this.searchParames){
                if (this.searchParames[key]) {
                    if (key == 'createDate') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'date'
                        })
                    } else if (key == 'reviewStatus') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'enumeration'
                        })
                    } else {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'string'
                        })
                    }
                }
            }
            this.$emit('checkSearch',searchDate)
            this.handleClose()
        },
        handleClose () {
            this.searchData.show = false
        },
        handleReset () {
            
            this.searchParames.serviceCompanyId = ''//服务商名称
            this.searchParames.invoiceTitle =''//收据编号
            this.searchParames.creditCode =''//收款账号
            this.searchParames.createBy =''//申请人
            this.searchParames.createDate =''//审核时间
            this.searchParames.reviewStatus = ''
            this.$emit('resetSearch')
            this.$refs.searchParames.resetFields()
        },
        postProviderList () { //获取所有服务商
            this.$post(this.$api.postProviderList).then(response => {
            if (response.data.succeed) {
                this.companyData = response.data.data
            }
            })
        },
    },
    computed: {
      changeDialog () {
        return this.searchData.show
      }
    }, 
    watch: {
      changeDialog: {
        handler (curVal, oldVal) {
          if (curVal) {
              this.postProviderList()
            this.searchParames.invoiceTitle = this.searchData.invoiceTitle
          } else {
          }
        }
      }
    },
};
</script>

<style>
#seachDialog .el-dialog{
    padding-bottom: 0; 
    overflow-x: hidden;
}
#seachDialog .el-dialog__footer{
    border-top: #f4f4f4 solid 1px;
}
.ant-modal-body{
    padding: 0
}
</style>
